<template>
	<yd-layout id='teamTrend' class=''>
		<yd-infinitescroll v-show='dataList.length>0' :callback="getArticleLst" ref="infinitescrollDemo">

			<div slot="list" class="list" @click="goTeamTrendDetail(item)" v-for="item in dataList">
				<div class="title c_text_ellipsis_2 c_size_34_48">{{item.title}}</div>
				<div class="label">
					<!--<div>{{item.share_count}}位伙伴已阅</div>
					<span></span>-->
					<div class="time">{{item.newTime}}</div>
				</div>
			</div>
			<!-- 数据全部加载完毕显示 -->
			<span slot="doneTip">没有更多数据了~~</span>

			<!-- 加载中提示，不指定，将显示默认加载中图标 -->
			<!--<img slot="loadingTip" src="path/img/loading.svg"/>-->
		</yd-infinitescroll>
		<NoList v-show='dataList.length==0'>
			<img slot='img' src="../../assets/kong_3.png" alt="" />
		</NoList>
		<yd-backtop></yd-backtop>

	</yd-layout>
</template>

<script>
	import { InfiniteScroll } from 'vue-ydui/dist/lib.rem/infinitescroll';
	import { BackTop } from 'vue-ydui/dist/lib.rem/backtop';
	export default {
		components: {
			[InfiniteScroll.name]: InfiniteScroll,
			[BackTop.name]: BackTop,
		},
		data() {
			return {
				dataList: [],
				pageNum: 1,
				pageCount: 10,
			}
		},
		created() {},
		watch: {

		},
		computed: {

		},
		mounted() {
			document.title = '团队动态'
			this.getArticleLst()
		},
		methods: {
			goTeamTrendDetail(item) {
				this.$router.push({
					name: 'teamTrendDetail',
					query: {
						id: item.id
					}
				})
			},
			getArticleLst() {
				this.$root.ajax({
					name: 'article/lst',
					type: 'get',
					params: {
						page: this.pageNum,
						count: this.pageCount,
						cate_id: this.$route.query.cate_id
					}
				}).then((d) => {
					for(let a = 0; a < d.data.article_list.length; a++) {
						d.data.article_list[a].newTime = this.$root.getDate(new Date(d.data.article_list[a].create_time * 1000))
					}
					this.dataList = [...this.dataList, ...d.data.article_list];
					if(this.dataList.length >= d.data.article_total) {
						/* 所有数据加载完毕 */
						this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
						return;
					}

					/* 单次请求数据完毕 */
					this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');

					this.pageNum++;
				})
			},
		}
	}
</script>

<style lang="scss">
	@import './teamTrend.scss';
</style>